(yank, yank-pop): Don't activate the mark.
authorRichard M. Stallman <rms@gnu.org>
Sun, 16 May 1993 15:39:39 +0000 (15:39 +0000)
committerRichard M. Stallman <rms@gnu.org>
Sun, 16 May 1993 15:39:39 +0000 (15:39 +0000)
(mark-whole-buffer, mark-word): Activate the mark.
(push-mark): Optional arg ACTIVATE.
(set-mark-command): Use that.

lisp/simple.el

index 9481c3da14f77a813f25f05c31562d8209166841..da522aca3ea8c42b56959f4cb2bb21187e7ae76e 100644 (file)
@@ -297,7 +297,7 @@ it is usually a mistake for a Lisp function to use any subroutine
 that uses or sets the mark."
   (interactive)
   (push-mark (point))
-  (push-mark (point-max))
+  (push-mark (point-max) nil t)
   (goto-char (point-min)))
 
 (defun count-lines-region (start end)
@@ -1103,9 +1103,14 @@ comes the newest one."
   (setq this-command 'yank)
   (let ((before (< (point) (mark t))))
     (delete-region (point) (mark t))
-    (set-mark (point))
+    (set-marker (mark-marker) (point) (current-buffer))
     (insert (current-kill arg))
-    (if before (exchange-point-and-mark)))
+    (if before
+       ;; This is like exchange-point-and-mark, but doesn't activate the mark.
+       ;; It is cleaner to avoid activation, even though the command
+       ;; loop would deactivate the mark because we inserted text.
+       (goto-char (prog1 (mark t)
+                    (set-marker (mark-marker) (point) (current-buffer))))))
   nil)
 
 (defun yank (&optional arg)
@@ -1123,7 +1128,11 @@ See also the command \\[yank-pop]."
                         ((eq arg '-) -1)
                         (t (1- arg)))))
   (if (consp arg)
-      (exchange-point-and-mark))
+      ;; This is like exchange-point-and-mark, but doesn't activate the mark.
+      ;; It is cleaner to avoid activation, even though the command
+      ;; loop would deactivate the mark because we inserted text.
+      (goto-char (prog1 (mark t)
+                  (set-marker (mark-marker) (point) (current-buffer)))))
   nil)
 
 (defun rotate-yank-pointer (arg)
@@ -1244,16 +1253,16 @@ purposes.  See the documentation of `set-mark' for more information."
   (interactive "P")
   (if (null arg)
       (progn
-       (push-mark)
-       (set-mark (mark t)))
+       (push-mark nil nil t))
     (if (null (mark t))
        (error "No mark set in this buffer")
       (goto-char (mark t))
       (pop-mark))))
 
-(defun push-mark (&optional location nomsg)
+(defun push-mark (&optional location nomsg activate)
   "Set mark at LOCATION (point, by default) and push old mark on mark ring.
-Displays \"Mark set\" unless the optional second arg NOMSG is non-nil.
+Display `Mark set' unless the optional second arg NOMSG is non-nil.
+Activate the mark if optional third arg ACTIVATE is non-nil.
 
 Novice Emacs Lisp programmers often try to use the mark for the wrong
 purposes.  See the documentation of `set-mark' for more information.
@@ -1269,6 +1278,7 @@ In Transient Mark mode, this does not activate the mark."
   (set-marker (mark-marker) (or location (point)) (current-buffer))
   (or nomsg executing-macro (> (minibuffer-depth) 0)
       (message "Mark set"))
+  (if activate (set-mark (mark t)))
   nil)
 
 (defun pop-mark ()
@@ -1757,7 +1767,8 @@ In programs, it is faster to call `forward-word' with negative arg."
   (push-mark
     (save-excursion
       (forward-word arg)
-      (point))))
+      (point))
+    nil t))
 
 (defun kill-word (arg)
   "Kill characters forward until encountering the end of a word.